#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <GL/glut.h>

// TimeStamp courant
int currentTick = 0;

// TimeStamp de départ de l'attente
int startWaitingTick = 0;

void initPacTexture(GLubyte* texData, int aTexWidth, int aTexHeight) {
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, aTexWidth,
            aTexHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
            texData);
}

int getMaxInt(int aFirstInt, int aSecondInt) {
    int maxInt = aFirstInt;

    if (aFirstInt < aSecondInt) {
        maxInt = aSecondInt;
    }

    return maxInt;
}

int getRandomIntUnder(int aMaxInt) {
    return rand() % aMaxInt;
}

void tick(int aTickValue) {
    currentTick += aTickValue;
}

int getCurrentTick() {
    return currentTick;
}

void wait(int aTimeValue) {

    clock_t wakeUpTime = (aTimeValue * CLOCKS_PER_SEC) + clock();
    while (wakeUpTime > clock()) {
        // Do nothing...
    }
}
